{{!
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
}}
{{#error}}
  <div class="text-error">{{.}}</div>
{{/error}}
{{#redirect_error}}
  <div class="text-error">{{.}}</div>
{{/redirect_error}}
{{#leader_redirect}}
  <div>You can find this page on the <a href="{{{.}}}">leader master's web UI</a>.</div>
{{/leader_redirect}}
{{^error}}
  <h2>Table: {{name}} ({{id}})</h2>
  <table class="table table-striped">
    <tbody>
    <tr><td>Version:</td><td>{{version}}</td></tr>
    <tr><td>State:</td><td>{{state}} {{#state_msg}}({{.}}){{/state_msg}}</td></tr>
    <tr><td>Column Count:</td><td>{{column_count}}</td></tr>
    <tr><td>Live Row Count:</td><td>{{table_live_row_count}}</td></tr>
    <tr><td>On-Disk Size (leaders only):</td><td>{{table_disk_size}}</td></tr>
    </tbody>
  </table>

  <h3>Schema</h3>
  <table class='table table-striped'>
    <thead><tr>
      <th>Column</th>
      <th>ID</th>
      <th>Type</th>
      <th>Encoding</th>
      <th>Compression</th>
      <th>Read default</th>
      <th>Write default</th>
      <th>Comment</th>
    </tr></thead>
    <tbody>
    {{#columns}}
      <tr>
        <th>
          {{#is_key}}<img src="{{base_url}}/key.png" width=12 height=6 />&nbsp;&nbsp;{{/is_key}}{{name}}
        </th>
        <td>{{id}}</a></td>
        <td>{{type}}</td>
        <td>{{encoding}}</td>
        <td>{{compression}}</td>
        <td>{{read_default}}</td>
        <td>{{write_default}}</td>
        <td>{{comment}}</td>
      </tr>
    {{/columns}}
    </tbody>
  </table>

  <h3>Partition Schema</h3>
  <pre>{{partition_schema}}</pre>

  <h3>Extra Config</h3>
  <pre>{{extra_config}}</pre>

  <h3>Tablets</h3>
  <h4>Summary</h4>

  <table class='table table-striped'>
    <thead><tr>
      <th>State</th>
      <th>Count</th>
      <th>Percentage</th>
    </tr></thead>
    <tbody>
    {{#tablets_summary}}
      <tr>
        <td>{{state}}</td>
        <td>{{count}}</td>
        <td>{{percentage}}</td>
      </tr>
    {{/tablets_summary}}
    </tbody>
  </table>

  <h4>Detail</h4>
  <a href='#detail' data-toggle='collapse'>(toggle)</a>
  <div id='detail' class='collapse'>
    <table data-toggle="table" class='table table-striped table-hover'>
      <thead><tr>
        <th>Tablet ID</th>
        {{{detail_partition_schema_header}}}
        <th>State</th>
        <th>Message</th>
        <th data-sorter="bytesSorter" data-sortable="true">On-Disk Size (leaders only)</th>
        <th>Peers</th>
      </tr></thead>
      <tbody>
      {{#tablets_detail}}
        <tr>
          <td>{{id}}</td>
          {{{partition_cols}}}
          <td>{{state}}</td>
          <td>{{state_msg}}</td>
          <td>{{on_disk_size}}</td>
          <td>
            <ul>
              {{#peers}}
                <li>{{#is_leader}}<b>LEADER: </b>{{/is_leader}}
                  {{^is_leader}}{{role}}: {{/is_leader}}
                  {{#target}}<a href="{{{.}}}">{{/target}}
                  {{text}}
                  {{#target}}</a>{{/target}}
                </li>
              {{/peers}}
            </ul>
          </td>
        </tr>
      {{/tablets_detail}}
      </tbody>
    </table>
  </div>

  {{#replica_distribution}}
  <h3>Tablet Replica Distribution</h3>
  <table class='table table-striped table-hover'>
    <tbody>
      <tr><td>Min Count</td><td>{{min_count}}</td></tr>
      <tr><td>Max Count</td><td>{{max_count}}</td></tr>
      <tr>
        <td>
          <p>Skew <small>(<a href="#skew-help" data-toggle="collapse">?</a>)</small></p>
          <div id="skew-help" class="collapse text-muted"><p>
            Skew is the difference between the max and min replica counts.
            It measures how imbalanced the table is.
          </p></div>
        </td>
        <td>{{skew}}</td>
      </tr>
    </tbody>
  </table>
  <table class='table table-striped table-hover'>
    <thead><tr><th>Tablet Server</th><th>Replica Count</th></thead>
    <tbody>
      {{#counts}}
        <tr><td>{{ts_uuid}}</td><td>{{count}}</td></tr>
      {{/counts}}
    </tbody>
  </table>
  {{/replica_distribution}}

  <h3>Impala CREATE TABLE statement</h3>
  {{! Unusual formatting below because <pre> preserves whitespace in the output. }}
  <pre><code>CREATE EXTERNAL TABLE `{{impala_table_name}}` STORED AS KUDU
TBLPROPERTIES(
    'kudu.table_name' = '{{name}}',
    'kudu.master_addresses' = '{{master_addresses}}')</code></pre>

  <h3>Tasks</h3>
  <table class='table table-striped'>
    <tr>
      <th>Task Name</th>
      <th>State</th>
      <th>Time</th>
      <th>Description</th>
    </tr>
    <tbody>
    {{#tasks}}
      <tr>
        <td>{{name}}</td>
        <td>{{state}}</td>
        <td>{{time}}</td>
        <td>{{description}}</td>
      </tr>
    {{/tasks}}
    </tbody>
  </table>
{{/error}}
